// pages/home/home.js
Page({
  data: {
    // 页面数据
  },

  onLoad() {
    // 页面加载
  },

  // 跳转到倒数日页面
  goToCountdown() {
    wx.navigateTo({
      url: '/pages/countdown/countdown'
    });
  },

  // 跳转到班级课表页面
  goToSchedule() {
    wx.navigateTo({
      url: '/pages/schedule/schedule'
    });
  },

  // 跳转到帮助页面
  goToHelp(e) {
    const type = e.currentTarget.dataset.type;
    let url = '';
    
    switch(type) {
      case 'homework':
        url = '/pages/class/homework/index';
        break;
      case 'checkin':
        url = '/pages/class/checkin/index';
        break;
      case 'score':
        url = '/pages/class/score/index';
        break;
      case 'comment':
        url = '/pages/class/comment/index';
        break;
      default:
        return;
    }
    
    wx.navigateTo({
      url: url
    });
  },

  // 跳转到客服页面
  goToService() {
    wx.showModal({
      title: '客服服务',
      content: '客服功能正在开发中，敬请期待！',
      showCancel: false
    });
  },

  // 跳转到发布页面
  goToPublish() {
    wx.showActionSheet({
      itemList: ['发布作业', '发布通知', '发布打卡', '发布成绩'],
      success: (res) => {
        const actions = ['homework', 'notice', 'checkin', 'score'];
        const pages = [
          '/pages/class/homework/index',
          '/pages/class/notice/create-notice/index',
          '/pages/class/checkin/create-checkin/index',
          '/pages/class/score/index'
        ];
        
        if (res.tapIndex >= 0 && res.tapIndex < pages.length) {
          wx.navigateTo({
            url: pages[res.tapIndex]
          });
        }
      }
    });
  }
});
